#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: solution.py 
@version:
@time: 2024/01/22 
"""
def dfs(nums, remaining, combination, indices, index):
    global minIndexSum, targetCount, result

    if remaining == 0:
        total = 0
        indexSumTemp = 0
        for i in range(3):
            total += combination[i]  # 计算组合的元素总和
            indexSumTemp += indices[i]  # 计算索引总和
        if total == targetCount and indexSumTemp < minIndexSum:  # 满足条件时更新结果
            minIndexSum = indexSumTemp
            result = combination[:]
    else:
        for i in range(index, len(nums)):
            combination.append(nums[i])  # 添加元素到组合
            indices.append(i)  # 添加索引
            dfs(nums, remaining - 1, combination, indices, i + 1)  # 递归调用
            combination.pop()  # 回溯：移除最后一个元素
            indices.pop()  # 回溯：移除最后一个索引


minIndexSum = float('inf')
targetCount = int(input())
nums = list(map(int, input().strip('[\]').split(',')))
result = []

dfs(nums, 3, [], [], 0)

output = '[' + ','.join(map(str, result)) + ']'
print(output)
"""
input

```text
9
[1,4,5,2,0,2]
```

output

```text
[4,5,0]
```
"""

